home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_5.lha / 5_5 / 5_5a4.c < prev    next >
Text File  |  1993-08-08  |  781b  |  31 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. tatic tree* term(istream& input)
  6.  
  7.    tree* left = prim(input);
  8.  
  9.    for (;;)
  10. switch (curr_tok.type)
  11.     {
  12.     case MUL:
  13.     case DIV:
  14. f (debug) cout << "term() sees +/-\n";    // DELETE
  15. f (debug) { cout << "term():left:\n"; left->print(0); }    // DELETE
  16.     tree* head = new tree;
  17.     head->type = curr_tok.type;
  18.     head->left = left;
  19.     get_token(input);    // eat '*','/'
  20.     head->right = prim(input);
  21.     left = head;
  22. f (debug) { cout << "term():new left:\n"; left->print(0); }    // DELETE
  23.     break;
  24.  
  25.     default:        // collapse node
  26. f (debug) cout << "term() sees other\n";    // DELETE
  27. f (debug) { cout << "left:\n"; left->print(0); }    // DELETE
  28.     return left;
  29.     }
  30.  
  31.